Give the action muxer a widget
authorMatthias Clasen <mclasen@redhat.com>
Sat, 15 Jun 2019 23:08:39 +0000 (23:08 +0000)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 18 Jun 2019 10:12:50 +0000 (06:12 -0400)
This will be used in the future to obtain
widget class actions.

gtk/gtkactionmuxer.c
gtk/gtkactionmuxerprivate.h
gtk/gtkapplication.c
gtk/gtkwidget.c

index 5020f6935905cff33af9198defac9ff40c38630f..f358f8cbbd6a9be8390d5e2d9e0d4e350b36314b 100644 (file)
@@ -25,6 +25,7 @@
 #include "gtkactionobserverprivate.h"
 #include "gtkintl.h"
 #include "gtkmarshalers.h"
+#include "gtkwidget.h"
 
 #include <string.h>
 
@@ -69,6 +70,8 @@ struct _GtkActionMuxer
   GHashTable *groups;
   GHashTable *primary_accels;
   GtkActionMuxer *parent;
+
+  GtkWidget *widget;
 };
 
 G_DEFINE_TYPE_WITH_CODE (GtkActionMuxer, gtk_action_muxer, G_TYPE_OBJECT,
@@ -79,6 +82,7 @@ enum
 {
   PROP_0,
   PROP_PARENT,
+  PROP_WIDGET,
   NUM_PROPERTIES
 };
 
@@ -592,6 +596,10 @@ gtk_action_muxer_get_property (GObject    *object,
       g_value_set_object (value, gtk_action_muxer_get_parent (muxer));
       break;
 
+    case PROP_WIDGET:
+      g_value_set_object (value, muxer->widget);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     }
@@ -611,6 +619,10 @@ gtk_action_muxer_set_property (GObject      *object,
       gtk_action_muxer_set_parent (muxer, g_value_get_object (value));
       break;
 
+    case PROP_WIDGET:
+      muxer->widget = g_value_get_object (value);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     }
@@ -664,6 +676,13 @@ gtk_action_muxer_class_init (GObjectClass *class)
                                                  G_PARAM_READWRITE |
                                                  G_PARAM_STATIC_STRINGS);
 
+  properties[PROP_WIDGET] = g_param_spec_object ("widget", "Widget",
+                                                 "The widget that owns the muxer",
+                                                 GTK_TYPE_WIDGET,
+                                                 G_PARAM_READWRITE |
+                                                 G_PARAM_CONSTRUCT_ONLY |
+                                                 G_PARAM_STATIC_STRINGS);
+
   g_object_class_install_properties (class, NUM_PROPERTIES, properties);
 }
 
@@ -771,13 +790,16 @@ gtk_action_muxer_lookup (GtkActionMuxer *muxer,
 
 /*< private >
  * gtk_action_muxer_new:
+ * @widget: the widget to which the muxer belongs
  *
  * Creates a new #GtkActionMuxer.
  */
 GtkActionMuxer *
-gtk_action_muxer_new (void)
+gtk_action_muxer_new (GtkWidget *widget)
 {
-  return g_object_new (GTK_TYPE_ACTION_MUXER, NULL);
+  return g_object_new (GTK_TYPE_ACTION_MUXER,
+                       "widget", widget,
+                       NULL);
 }
 
 /*< private >
index 01b6f14bd18a8f5a1f37e0e624f6caa5007a26f3..190728fafddacb8ca25af0e784e84900d8905029 100644 (file)
@@ -21,6 +21,7 @@
 #define __GTK_ACTION_MUXER_H__
 
 #include <gio/gio.h>
+#include "gtkwidget.h"
 
 G_BEGIN_DECLS
 
@@ -33,7 +34,7 @@ G_BEGIN_DECLS
 typedef struct _GtkActionMuxer                              GtkActionMuxer;
 
 GType                   gtk_action_muxer_get_type                       (void);
-GtkActionMuxer *        gtk_action_muxer_new                            (void);
+GtkActionMuxer *        gtk_action_muxer_new                            (GtkWidget      *widget);
 
 void                    gtk_action_muxer_insert                         (GtkActionMuxer *muxer,
                                                                          const gchar    *prefix,
index cf3070e0884cdf8ae0f1392e4bbec1055264164d..f90fd827fcb3d0eb2ddbc2fd19f87a52dcfb9186 100644 (file)
@@ -394,7 +394,7 @@ gtk_application_init (GtkApplication *application)
 {
   GtkApplicationPrivate *priv = gtk_application_get_instance_private (application);
 
-  priv->muxer = gtk_action_muxer_new ();
+  priv->muxer = gtk_action_muxer_new (NULL);
 
   priv->accels = gtk_application_accels_new ();
 }
index 532aecb3cb5efd0d80f4117e82d3b6ce804f4082..444ecbe4ddc6601f451592d40bd56a644a5966f5 100644 (file)
@@ -11904,7 +11904,7 @@ _gtk_widget_get_action_muxer (GtkWidget *widget,
 
   if (create)
     {
-      muxer = gtk_action_muxer_new ();
+      muxer = gtk_action_muxer_new (widget);
       g_object_set_qdata_full (G_OBJECT (widget),
                                quark_action_muxer,
                                muxer,